package com.xiyi.shouxin.view.pojo;

import java.util.List;

import com.xiyi.shouxin.entity.admin.Menu;

import lombok.Getter;

@Getter
public class MenuView extends Menu {
    private List<RoleView> roles;
    public MenuView(Menu menu,List<RoleView> roles) {
        if (menu==null) {
            return;
        }
        this.setId(menu.getId());
        this.setName(menu.getName());
        this.setPath(menu.getPath());
        this.setTitle(menu.getTitle());
        this.setRequiresAuth(menu.getRequiresAuth());
        this.setOrder(menu.getOrder());
        this.setIcon(menu.getIcon());
        this.setPinTab(menu.getPinTab());
        this.setMenuType(menu.getMenuType());
        this.setComponentPath(menu.getComponentPath());
        this.setPid(menu.getPid());
        this.roles=roles;
    }

    public Menu toMenu() {
        Menu menu = new Menu();
        menu.setId(this.getId());
        menu.setName(this.getName());
        menu.setPath(this.getPath());
        menu.setTitle(this.getTitle());
        menu.setRequiresAuth(this.getRequiresAuth());
        menu.setOrder(this.getOrder());
        menu.setIcon(this.getIcon());
        menu.setPinTab(this.getPinTab());
        menu.setMenuType(this.getMenuType());
        menu.setComponentPath(this.getComponentPath());
        menu.setPid(this.getPid());
        return menu;
    }
}
